package ift605.tp3.b.resolvers;

import ift605.tp3.utils.equations.IEquation;
import ift605.tp3.utils.equations.SummativeEq;
import ift605.tp3.utils.equations.UnknownEquationTypeException;

public class SummativeResolverAgent extends AbstractResolverAgent
{
    private static final long serialVersionUID = 1L;
    
    @Override
    protected IEquation derive(IEquation eq)
    {
        if (eq instanceof SummativeEq)
        {
            try
            {
                final SummativeEq polyEquation = (SummativeEq) eq;
                final IEquation dFirst = askDerive(polyEquation.getFirst());
                final IEquation dSecond = askDerive(polyEquation.getSecond());
                return new SummativeEq(dFirst, dSecond);
            }
            catch (final UnknownEquationTypeException e)
            {
                return null;
            }
        }
        return null;
    }
    
    @Override
    protected String getType()
    {
        return SummativeEq.class.getName();
    }
}
